﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace XChipUtils
{
    public interface IUtilsHelper
    {
        #region 操作和遍历可视化树
        /// <summary>
        /// 获取指定父元素下的所有 TextBox 控件
        /// </summary>
        /// <param name="parent">父元素</param>
        /// <returns>TextBox 控件列表</returns>
        List<TextBox> GetAllTextBoxes(DependencyObject parent);

        /// <summary>
        /// 通过名称查找 TextBox（不区分大小写）
        /// </summary>
        /// <param name="parent">父元素</param>
        /// <param name="name">要查找的 TextBox 名称</param>
        /// <returns>找到的 TextBox 或 null</returns>
        TextBox FindTextBoxByNameIgnoreCase(DependencyObject parent, string name);

        /// <summary>
        /// 获取指定父元素下的所有指定类型的控件
        /// </summary>
        /// <typeparam name="T">控件类型</typeparam>
        /// <param name="parent">父元素</param>
        /// <returns>控件列表</returns>
        List<T> GetVisualChildren<T>(DependencyObject parent) where T : DependencyObject;

        /// <summary>
        /// 通过名称查找指定类型的控件（不区分大小写）
        /// </summary>
        /// <typeparam name="T">控件类型</typeparam>
        /// <param name="parent">父元素</param>
        /// <param name="name">要查找的控件名称</param>
        /// <returns>找到的控件或 null</returns>
        T FindVisualChildByNameIgnoreCase<T>(DependencyObject parent, string name) where T : FrameworkElement;

        /// <summary>
        /// 查找父元素中的指定类型的父控件
        /// </summary>
        /// <typeparam name="T">父控件类型</typeparam>
        /// <param name="child">子元素</param>
        /// <returns>找到的父控件或 null</returns>
        T FindVisualParent<T>(DependencyObject child) where T : DependencyObject;
        #endregion

    }

}





